#ifndef BLOCKLIST_H
#define BLOCKLIST_H

#include <vector>
#include "Matrix.h"
#include "BitStream.h"

using std::vector;

class BlockList
{
public:
    BlockList() {}
    ~BlockList() { _blockList.clear(); }

    void append(const Matrix &block) { _blockList.push_back(block); }

    void clear() {_blockList.clear();}

    void initialize(uint8_t *buff, int width, int height, int totalBlocks, int columnAndRowSize);

    vector<Matrix>::iterator begin() { return _blockList.begin(); }
    vector<Matrix>::const_iterator end() const { return _blockList.end(); }

    vector<Matrix>::iterator it;
    uint8_t* mergeBlocks(int width, int height, int columnLength);

    static Matrix* getBlockAtCoord(int x, int y, uint8_t* data, int width, int height, int columnLength);

private:
    vector<Matrix> _blockList;

    void initBlockList(int totalBlocks, int columnAndRowSize);
    void devideIntoBlocks(uint8_t *buff, int width, int height, int columnAndRowSize);
};

#endif // BLOCKLIST_H
